<template>
	<view class="container">
		<view class="s-cells">
			<textarea class="s-textarea" v-model="content" placeholder="发表你的评论..." placeholder-class="s-phcolor-color" maxlength="100" @input="content_input"/> 
			<view class="s-textarea-counter">{{content_length}}/100</view>
		</view>
		<view class="s-cmt-btn">
			<s-button type="danger" @click="set_consult_evaluate">发表</s-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:'',
				pid:'',
				content:'',
				content_length:0
			}
		},
		onLoad(options){
			this.id = options.id
			this.pid = options.pid
		},
		methods: {
			//咨询评论
			async set_consult_evaluate() {
				if(this.content==''){
					return await this.$s.uniApi.showToast({title: '请发表你的评论...'});
				}
				await this.$s.model.consult.setConsultEvaluate({
					id:this.id,
					pid:this.pid,
					content:this.content
				})
				return await this.$s.uniApi.navigateBack({})
			},
			//监听input
			content_input(){
				this.content_length = this.$s.api.getLength(this.content)
			}
		}
	}
</script>

<style lang="scss" scoped>
@import 'consult_evaluate.scss';
</style>
